package org.example.utils;

import org.example.Dto.AdminDto;
import java.text.ParseException;
import java.util.Date;


/**
 * @Author : zhangbo
 * @data : 2024/7/15
 * @description :
 */
public class batchCreateUtils {
    public static void main(String[] args) throws ParseException {
    }
    public static AdminDto  insert() throws ParseException {
        //随机生成insert语句参数
        //1.生成姓名
        String name = ChineseUtil.randomChineseName();
        String password=ChineseUtil.randomPassword();
        String phone = ChineseUtil.randomPhone();
        Date date = ChineseUtil.getTime();

//        return createSql(AdminDto.builder()
//                .username(name)
//                .password(password)
//                .phone(phone)
//                .loginTime(time)
//                .exitTime(null)
//                .updateTime(new Date().toString())
//                .updatePerson("admin")
//                .status("0")
//                .build());
       return AdminDto.builder()
               .username(name)
               .password(password)
               .phone(phone)
               .loginTime(date)
               .exitTime(null)
               .updateTime(new Date())
               .updatePerson("admin")
               .status("0")
               .build();
    }
    public static String createSql(AdminDto dto) {
        //动态生成insert语句
        StringBuffer sql = new StringBuffer();
        sql.append("insert into admin ( username,password, phone, loginTime, exitTime,updateTime,updatePerson,status )")
                .append("values ( ")
                //字符串做insert需要加单引号    ' name','department'
                .append(" '").append(dto.getUsername()).append(" '").append(" ").append(",")
                .append(" '").append(dto.getPassword()).append("' ").append(" ").append(",")
                .append(" '").append(dto.getPhone()).append("' ").append(" ").append(" ,")
                .append(" '").append(dto.getLoginTime()).append(" '").append(" ").append(",")
                .append(" '").append(dto.getExitTime()).append(" '").append(" ").append(",")
                .append(" '").append(dto.getUpdateTime()).append("' ").append(" ").append(" ,")
                .append(" '").append(dto.getUpdatePerson()).append(" '").append(" ").append(",")
                .append(" '").append(dto.getStatus()).append(" '").append(" ")
                .append(")");
        return sql.toString();
    }
}
